const http = require("http");
const url = require("url");
const fs = require("fs");
const sever = http.createServer((req, res) => {
  console.log(req.url);
  let query = url.parse(req.url, true).query;
  console.log(query);
  if (typeof query.username !== "undefined") {
    // 通过文件系统存储数据
    try {
      fs.writeFileSync("./data.json", JSON.stringify(query));
      res.write("success");
    } catch (err) {
      console.log(err);
      res.write("error")
    }
  }
  res.end();
})
sever.listen(8960)